/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.wpi.first.wpilibj.defaultCode;

/**
 *
 * @author robotics
 */
public class DriveMtrEncoder
{
    int count = 0;
    int currSign = 1;
    int prevCount = 0;
    int currCount = 0;

    /**
     * @return
     */
    public double pidGet()
    {
        updateCount();
        return count;
    }

    public void setSign(int sign)
    {
        if(sign != currSign)
        {
        updateCount();
        }
        currSign = sign;
    }

    public int getCount()
    {
        return count;
    }

    private void updateCount()
    {
        currCount = 0; //should get the actual current encoder value
        int addTo = currCount - prevCount;
        prevCount = currCount;
        count += currSign*addTo;
    }
}
